<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>DefaultStackPresentationHandler.swift - Slather</title>
<link href="slather.css" media="all" rel="stylesheet">
</head>
<body>
<header><div class="row"><a href="index.html"><img src="logo.jpg" alt="Slather logo"></a></div></header><div class="row"><div id="reports">
<h2 class="cov_title">
<span>Coverage for "DefaultStackPresentationHandler.swift" : </span><span class="cov_high">91.53%</span>
</h2>
<h4 class="cov_subtitle">(54 of 59 relevant lines covered)</h4>
<h4 class="cov_filepath">RouteComposer/Classes/Router/Helpers/DefaultStackPresentationHandler.swift</h4>
<table class="source_code">
<tr class="never">
<td class="num">1</td>
<td class="src"><pre><code class="objc">//</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">2</td>
<td class="src"><pre><code class="objc">// RouteComposer</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">3</td>
<td class="src"><pre><code class="objc">// DefaultStackPresentationHandler.swift</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">4</td>
<td class="src"><pre><code class="objc">// https://github.com/ekazaev/route-composer</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">5</td>
<td class="src"><pre><code class="objc">//</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">6</td>
<td class="src"><pre><code class="objc">// Created by Eugene Kazaev in 2018-2022.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">7</td>
<td class="src"><pre><code class="objc">// Distributed under the MIT license.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">8</td>
<td class="src"><pre><code class="objc">//</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">9</td>
<td class="src"><pre><code class="objc">// Become a sponsor:</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">10</td>
<td class="src"><pre><code class="objc">// https://github.com/sponsors/ekazaev</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">11</td>
<td class="src"><pre><code class="objc">//</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">12</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">13</td>
<td class="src"><pre><code class="objc">import UIKit</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">14</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">15</td>
<td class="src"><pre><code class="objc">/// Default implementation of `StackPresentationHandler`</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">16</td>
<td class="src"><pre><code class="objc">public struct DefaultStackPresentationHandler: StackPresentationHandler, MainThreadChecking {</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">17</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">18</td>
<td class="src"><pre><code class="objc">    // MARK: Properties</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">19</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">20</td>
<td class="src"><pre><code class="objc">    /// `Logger` instance to be used by `DefaultRouter`.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">21</td>
<td class="src"><pre><code class="objc">    public let logger: Logger?</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">22</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">23</td>
<td class="src"><pre><code class="objc">    /// `ContainerAdapter` instance.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">24</td>
<td class="src"><pre><code class="objc">    public let containerAdapterLocator: ContainerAdapterLocator</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">25</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">26</td>
<td class="src"><pre><code class="objc">    // MARK: Methods</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">27</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">28</td>
<td class="src"><pre><code class="objc">    /// Constructor</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">29</td>
<td class="src"><pre><code class="objc">    ///</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">30</td>
<td class="src"><pre><code class="objc">    /// Parameters</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">31</td>
<td class="src"><pre><code class="objc">    ///   - logger: A `Logger` instance to be used by the `DefaultRouter`.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">32</td>
<td class="src"><pre><code class="objc">    ///   - containerAdapterLocator: A `ContainerAdapterLocator` instance to be used by the `DefaultRouter`.</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">33</td>
<td class="src"><pre><code class="objc">    public init(logger: Logger? = RouteComposerDefaults.shared.logger,</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="covered">
<td class="num">34</td>
<td class="src"><pre><code class="objc">                containerAdapterLocator: ContainerAdapterLocator = RouteComposerDefaults.shared.containerAdapterLocator) {</code></pre></td>
<td class="coverage">45x</td>
</tr>
<tr class="covered">
<td class="num">35</td>
<td class="src"><pre><code class="objc">        self.logger = logger</code></pre></td>
<td class="coverage">45x</td>
</tr>
<tr class="covered">
<td class="num">36</td>
<td class="src"><pre><code class="objc">        self.containerAdapterLocator = containerAdapterLocator</code></pre></td>
<td class="coverage">45x</td>
</tr>
<tr class="covered">
<td class="num">37</td>
<td class="src"><pre><code class="objc">    }</code></pre></td>
<td class="coverage">45x</td>
</tr>
<tr class="never">
<td class="num">38</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="covered">
<td class="num">39</td>
<td class="src"><pre><code class="objc">    public func dismissPresented(from viewController: UIViewController, animated: Bool, completion: @escaping (_: RoutingResult) -&gt; Void) {</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="covered">
<td class="num">40</td>
<td class="src"><pre><code class="objc">        assertIfNotMainThread(logger: logger)</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="covered">
<td class="num">41</td>
<td class="src"><pre><code class="objc">        if let presentedController = viewController.presentedViewController {</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="covered">
<td class="num">42</td>
<td class="src"><pre><code class="objc">            if !presentedController.isBeingDismissed {</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">43</td>
<td class="src"><pre><code class="objc">                viewController.dismiss(animated: animated) {</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">44</td>
<td class="src"><pre><code class="objc">                    self.logger?.log(.info("Dismissed all the view controllers presented from \(String(describing: viewController))"))</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">45</td>
<td class="src"><pre><code class="objc">                    completion(.success)</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">46</td>
<td class="src"><pre><code class="objc">                }</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">47</td>
<td class="src"><pre><code class="objc">            } else {</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="missed">
<td class="num">48</td>
<td class="src"><pre><code class="objc">                completion(.failure(RoutingError.compositionFailed(.init("Attempt to dismiss \(String(describing: presentedController)) while it is being dismissed"))))</code></pre></td>
<td class="coverage">!</td>
</tr>
<tr class="covered">
<td class="num">49</td>
<td class="src"><pre><code class="objc">            }</code></pre></td>
<td class="coverage">10x</td>
</tr>
<tr class="covered">
<td class="num">50</td>
<td class="src"><pre><code class="objc">        } else {</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="covered">
<td class="num">51</td>
<td class="src"><pre><code class="objc">            completion(.success)</code></pre></td>
<td class="coverage">93x</td>
</tr>
<tr class="covered">
<td class="num">52</td>
<td class="src"><pre><code class="objc">        }</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="covered">
<td class="num">53</td>
<td class="src"><pre><code class="objc">    }</code></pre></td>
<td class="coverage">103x</td>
</tr>
<tr class="never">
<td class="num">54</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">55</td>
<td class="src"><pre><code class="objc">    public func makeVisibleInParentContainers(_ viewController: UIViewController,</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">56</td>
<td class="src"><pre><code class="objc">                                              animated: Bool,</code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="covered">
<td class="num">57</td>
<td class="src"><pre><code class="objc">                                              completion: @escaping (RoutingResult) -&gt; Void) {</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">58</td>
<td class="src"><pre><code class="objc">        var parentViewControllers = viewController.allParents</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">59</td>
<td class="src"><pre><code class="objc">        let topParentViewController = parentViewControllers.last</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">60</td>
<td class="src"><pre><code class="objc">        func makeVisible(viewController: UIViewController, completion: @escaping (RoutingResult) -&gt; Void) {</code></pre></td>
<td class="coverage">354x</td>
</tr>
<tr class="covered">
<td class="num">61</td>
<td class="src"><pre><code class="objc">            assertIfNotMainThread(logger: logger)</code></pre></td>
<td class="coverage">354x</td>
</tr>
<tr class="covered">
<td class="num">62</td>
<td class="src"><pre><code class="objc">            guard !parentViewControllers.isEmpty else {</code></pre></td>
<td class="coverage">354x</td>
</tr>
<tr class="covered">
<td class="num">63</td>
<td class="src"><pre><code class="objc">                if !animated,</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">64</td>
<td class="src"><pre><code class="objc">                   let topParentViewController,</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">65</td>
<td class="src"><pre><code class="objc">                   topParentViewController.isViewLoaded {</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">66</td>
<td class="src"><pre><code class="objc">                    topParentViewController.view.layoutIfNeeded()</code></pre></td>
<td class="coverage">2x</td>
</tr>
<tr class="covered">
<td class="num">67</td>
<td class="src"><pre><code class="objc">                }</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">68</td>
<td class="src"><pre><code class="objc">                completion(.success)</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">69</td>
<td class="src"><pre><code class="objc">                return</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">70</td>
<td class="src"><pre><code class="objc">            }</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">71</td>
<td class="src"><pre><code class="objc">            do {</code></pre></td>
<td class="coverage">156x</td>
</tr>
<tr class="covered">
<td class="num">72</td>
<td class="src"><pre><code class="objc">                let parentViewController = parentViewControllers.removeFirst()</code></pre></td>
<td class="coverage">156x</td>
</tr>
<tr class="covered">
<td class="num">73</td>
<td class="src"><pre><code class="objc">                if let container = parentViewController as? ContainerViewController {</code></pre></td>
<td class="coverage">156x</td>
</tr>
<tr class="covered">
<td class="num">74</td>
<td class="src"><pre><code class="objc">                    let containerAdapter = try containerAdapterLocator.getAdapter(for: container)</code></pre></td>
<td class="coverage">156x</td>
</tr>
<tr class="covered">
<td class="num">75</td>
<td class="src"><pre><code class="objc">                    guard !containerAdapter.isVisible(viewController) else {</code></pre></td>
<td class="coverage">156x</td>
</tr>
<tr class="covered">
<td class="num">76</td>
<td class="src"><pre><code class="objc">                        logger?.log(.info("View controller \(String(describing: viewController)) is visible in \(String(describing: container)). No action needed."))</code></pre></td>
<td class="coverage">113x</td>
</tr>
<tr class="covered">
<td class="num">77</td>
<td class="src"><pre><code class="objc">                        return makeVisible(viewController: parentViewController, completion: completion)</code></pre></td>
<td class="coverage">113x</td>
</tr>
<tr class="covered">
<td class="num">78</td>
<td class="src"><pre><code class="objc">                    }</code></pre></td>
<td class="coverage">113x</td>
</tr>
<tr class="covered">
<td class="num">79</td>
<td class="src"><pre><code class="objc">                    containerAdapter.makeVisible(viewController, animated: animated, completion: { result in</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">80</td>
<td class="src"><pre><code class="objc">                        guard result.isSuccessful else {</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="missed">
<td class="num">81</td>
<td class="src"><pre><code class="objc">                            completion(result)</code></pre></td>
<td class="coverage">!</td>
</tr>
<tr class="missed">
<td class="num">82</td>
<td class="src"><pre><code class="objc">                            return</code></pre></td>
<td class="coverage">!</td>
</tr>
<tr class="covered">
<td class="num">83</td>
<td class="src"><pre><code class="objc">                        }</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">84</td>
<td class="src"><pre><code class="objc">                        self.logger?.log(.info("Made \(String(describing: viewController)) visible in \(String(describing: container))"))</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">85</td>
<td class="src"><pre><code class="objc">                        makeVisible(viewController: parentViewController, completion: completion)</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">86</td>
<td class="src"><pre><code class="objc">                    })</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">87</td>
<td class="src"><pre><code class="objc">                } else {</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="missed">
<td class="num">88</td>
<td class="src"><pre><code class="objc">                    makeVisible(viewController: parentViewController, completion: completion)</code></pre></td>
<td class="coverage">!</td>
</tr>
<tr class="covered">
<td class="num">89</td>
<td class="src"><pre><code class="objc">                }</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">90</td>
<td class="src"><pre><code class="objc">            } catch {</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="missed">
<td class="num">91</td>
<td class="src"><pre><code class="objc">                completion(.failure(error))</code></pre></td>
<td class="coverage">!</td>
</tr>
<tr class="covered">
<td class="num">92</td>
<td class="src"><pre><code class="objc">            }</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">93</td>
<td class="src"><pre><code class="objc">        }</code></pre></td>
<td class="coverage">43x</td>
</tr>
<tr class="covered">
<td class="num">94</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">95</td>
<td class="src"><pre><code class="objc">        makeVisible(viewController: viewController, completion: completion)</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="covered">
<td class="num">96</td>
<td class="src"><pre><code class="objc">    }</code></pre></td>
<td class="coverage">198x</td>
</tr>
<tr class="never">
<td class="num">97</td>
<td class="src"><pre><code class="objc"></code></pre></td>
<td class="coverage"></td>
</tr>
<tr class="never">
<td class="num">98</td>
<td class="src"><pre><code class="objc">}</code></pre></td>
<td class="coverage"></td>
</tr>
</table>
</div></div>
<footer><div class="row">
<p><a href="https://github.com/SlatherOrg/slather">Fork me on Github</a></p>
<p>&copy; 2022 Slather</p>
</div></footer><script src="highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script>
</body>
</html>
